﻿(function () {
	tinymce.create("tinymce.plugins.MindforPlugin", {
		init: function (ed, url) {
			var folderId = ed.settings.mindfor_folder_id;
			var fileUrl = "/Admin/Files";
			if (folderId)
				fileUrl += "?folderId=" + folderId;

			// commands
			ed.addCommand("cmdMindforFiles", function () {
				ed.windowManager.open({
					file: fileUrl,
					width: 800,
					height: 700,
					inline: 1
				}, {
					plugin_url: url
				});
			});

			// buttons
			ed.addButton("mindforFiles", {
				title: "Файлы и картики",
				cmd: "cmdMindforFiles",
				image: url + "/icon.png"
			});
		},

		getInfo: function () {
			return {
				longname: "Mindfor",
				author: "Mindfor Ltd.",
				authorurl: "http://www.mindfor.ru",
				infourl: "http://www.mindfor.ru",
				version: "1.0"
			};
		}
	});

	// Register plugin
	tinymce.PluginManager.add('mindfor', tinymce.plugins.MindforPlugin);
})();